import { Model } from 'pinia-orm';
import { Attr, Str, Uid, Num, Bool, HasOne, HasMany, BelongsTo, HasManyBy, BelongsToMany, MorphOne,
  MorphTo, MorphMany, MorphToMany, OnDelete
  } from 'pinia-orm/decorators';
import { useAxiosRepo } from '@pinia-orm/axios';
import { useAppConfig } from '@vben/hooks';
import type { MinishopStore, MinishopStoreResponse } from '../../views/uctoo/minishop_store/types.js';
//#region Human-Code Preservation

//#endregion Human-Code Preservation

const { apiURL } = useAppConfig(import.meta.env, import.meta.env.PROD);

export class uctoo_minishop_store extends Model {
  static override entity = 'uctoo_minishop_store'

@Uid() declare id: string 
@Str('') declare name: string 
@Str('') declare headimg: string 
@Str('') declare realname: string | null
@Str('') declare phone: string | null
@Str('') declare province_name: string 
@Str('') declare city_name: string 
@Str('') declare area_name: string 
@Uid() declare province_id: string | null
@Uid() declare city_id: string | null
@Uid() declare area_id: string | null
@Str('') declare address: string 
@Num(0) declare latitude: number | null
@Num(0) declare longitude: number | null
@Num(0) declare store: number 
@Num(0) declare selfetch: number 
@Str('') declare service_type: string | null
@Num(0) declare service_radius: number 
@Str('') declare service_province_ids: string | null
@Uid() declare service_city_ids: string | null
@Str('') declare service_area_ids: string | null
@Str('') declare openhours: string | null
@Str('') declare openweeks: string | null
@Num(0) declare status: number 
@Uid() declare creator: string | null
@Attr('') declare created_at: string 
@Attr('') declare updated_at: string 
@Attr('') declare deleted_at: string | null
@Str('') declare desc_info: string | null
@Uid() declare parent_id: string | null
@Str('') declare principal: string | null


  static override config = {
    axiosApi: {
        actions: {
            getuctooMinishopStoreList(page: number, pageSize: number, searchParams?: any){
                return useAxiosRepo(uctoo_minishop_store).api().get(`/uctoo/minishop_store/${pageSize}/${page}`, {
                  params: searchParams,
                  headers: { 'Content-Type': 'application/json;charset=utf-8',
                          'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                  },
                  baseURL: apiURL,
                  dataKey: 'minishopStores'
                })
            },
            getuctooMinishopStore(id: string){
              return useAxiosRepo(uctoo_minishop_store).api().get(`/uctoo/minishop_store/${id}`, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            adductooMinishopStore(data: Partial<MinishopStore>){
              return useAxiosRepo(uctoo_minishop_store).api().post('/uctoo/minishop_store/add', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            edituctooMinishopStore(data: any){
              return useAxiosRepo(uctoo_minishop_store).api().post('/uctoo/minishop_store/edit', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },
            deleteuctooMinishopStore(data: any){
              return useAxiosRepo(uctoo_minishop_store).api().post('/uctoo/minishop_store/del', data, {
                headers: { 'Content-Type': 'application/json;charset=utf-8',
                        'Authorization': `Bearer ${localStorage.getItem('accessToken')}` 
                },
                baseURL: apiURL,
              })
            },

//#region Human-Code Preservation

//#endregion Human-Code Preservation
        } 
    }
  }
}
